
#ifndef SKYSSP_COMMON_H
#define SKYSSP_COMMON_H

#include "skyos_wrapper.h"

#define SKYSSP_STREAM_COUNT_MAX			4
#define SKYSSP_CODEC_STREAM_MAX			4
#define SKYSSP_CODEC_INFO_MAX			32
#define SKYSSP_INDEX_FRAME_MAX			1024
#define SKYSSP_MIN_FRAME_SIZE			9

#define SKYSSP_FOURCC_HEADER			"SSPS"
#define SKYSSP_FILE_VERSION				0
#define SKYSSP_MEDIAINFO_HEADER			0x72
#define SKYSSP_CODECINFO_HEADER			0x75
#define SKYSSP_PTSINDEX_HEADER			0x7A
#define SKYSSP_END_FLAG					0x45 //"E"

typedef enum
{
	SKYSSP_Stream_type_none = 0,
	SKYSSP_Stream_type_audio,
	SKYSSP_Stream_type_video,
	SKYSSP_Stream_type_other
} e_skyssp_stream_type;

typedef enum
{
	SKYSSP_Coding_h263,
	SKYSSP_Coding_h264,
	SKYSSP_Coding_h264_baseline,
	SKYSSP_Coding_h264_mp,
	SKYSSP_Coding_h264_ap
}e_skyssp_video_coding;

typedef enum
{
	SKYSSP_Coding_amr,
	SKYSSP_Coding_aac,
	SKYSSP_Coding_mp3,
	SKYSSP_Coding_ac3
}e_skyssp_audio_coding;

typedef enum
{
	SKYSSP_Coding_text,
	SKYSSP_Coding_pic
}e_skyssp_other_coding;

typedef struct
{
	Int32 pts;
	Int32 byte;
}t_skyssp_ptsindex;

typedef struct _skyssp_stream_video_desc_
{
	Int32					frameintv;
	Int32					bitrate;
	Int16					width;
	Int16					height;
}t_skyssp_video_desc;

typedef struct _skyssp_stream_audio_desc_
{
	UInt8					encodemode;
	UInt32					samplerate;
	UInt8					channels;
	UInt8					samplebits;
}t_skyssp_audio_desc;

typedef struct _skyssp_stream_other_desc_
{
	UInt8					type;
}t_skyssp_other_desc;

typedef struct
{
	Int8					streamid;
	e_skyssp_stream_type	type;

	Int8					keyflag;

	union
	{
		struct
		{
			e_skyssp_video_coding coding;
			t_skyssp_video_desc desc;
		}v;
		struct
		{
			e_skyssp_audio_coding coding;
			t_skyssp_audio_desc desc;
		}a;
		struct
		{
			e_skyssp_other_coding coding;
			t_skyssp_other_desc desc;
		} other;
	}info;
}t_skyssp_stream_desc;

typedef struct
{
	Int8	stream_count;
	Int8	stream_info[SKYSSP_STREAM_COUNT_MAX][2];	// streamid, type
}t_skyssp_stream_info;

/////////////////////////////////////////////////////

#define SKYSSP_STREAM_PARA_MAX		32

enum
{
	SKYSSP_CHOOSE_FLAG_ADD,
	SKYSSP_CHOOSE_FLAG_REMOVE
};

typedef struct _skyssp_stream_desc_
{
	Int8					info_length;

	Int8					streamid;
	Int8					type;
	Int8					coding;
	Int8					keyflag;
	Int32					final_pts;
	Int8					stream_para[SKYSSP_STREAM_PARA_MAX];

	Int8					choose_flag;
	Int8					first_key_frame;
	Int8					first_read;
	Int32                   last_pts;
}skyssp_stream_desc;

//////////////////////////////////////////////////////

typedef struct _skyssp_codec_info_
{
	Int8				codec_info_size;
	Int8				streamid;
	UInt8				codec_info[SKYSSP_CODEC_INFO_MAX];
} skyssp_codec_info;

typedef struct _skyssp_codec_info_package_
{
	Int8				codecinfo_count;
	skyssp_codec_info	codec_info[SKYSSP_CODEC_STREAM_MAX];
} skyssp_codec_info_package;

#define DEBUG_INFO 

//////////////////////////////////////////////////////

#endif
